-- ================= MONSTERS

Fish = Enemy:new{
	exp = 10,
	searchrange = 50,						
	name = 'a_Fish',
	width = 17, 							
	height = 17,							
	movementSpeed = 2,							
	dmg = 5,						
	attackrange = 3,
	attackrate = 0.5,
	expWhenKilled = 10,
	image = {
		"resources/greenfish.png" -- 1 - north
	},
	team = 2
}


redfish = Fish:new{
	name = 'red_fish',
	sprite = "resources/greenfish_angry.png",
	image = { 
		"resources/greenfish_angry.png", -- 1 - north
		states = {attack = {"resources/cat.png"}}
	},
		
	stateList = {
		dead = {
			name = "dead",
			actions = {
				function (t) 
					shootFirebalAllDirections(t, 4, 20)
					t:changeState(t.stateList.destroy)
					t:giveExp()
					t:dropItem()
				end
			}
		}
	}, 
	currentState = Enemy.stateList.attack,
}

greenfish = Fish:new{
	name = 'green_fish',
	speed = 1,	
  states = States,
	sprite = "resources/greenfish_angry.png", -- 1 - north
	currentState = Gameelement.stateList.default
}

testfish = Fish:new{
	name = 'a test fish',
	image = { 
		"resources/greenfish.png", -- 1 - north
		states = {attack = {"resources/cat.png"}
			}
	},
	sprite = {
		states = {attack = {
    { -- 1 - north
	  	animation = {0,1,2,1},
	  	duration = 300
	  },
    { -- 2 - east
	  	animation = {3,4,5,4},
	  	duration = 300
	  },
    { -- 3 - south
	  	animation = {6,7,8,7},
	  	duration = 300
	  },
    { -- 4 - west
	  	animation = {9,10,11,10},
	  	duration = 300
	  },
    { -- 5 - northeast
	  	animation = {0,1,2,1},
	  	duration = 300
	  },
    { -- 6 - southeast
	  	animation = {6,7,8,7},
	  	duration = 300
	  },
    { -- 7 - southwest
	  	animation = {6,7,8,7},
	  	duration = 300
	  },
    { -- 8 - northwest
	  	animation = {0,1,2,1},
	  	duration = 300
	  },
		image = "resources/char.png",
		width = 24,
		height = 32	
		}
	},
	},
	currentState = Gameelement.stateList.default
  --states = States,
	--currentState = States.default
}

TestEnemy = Enemy:new{
	experiencepoints = 10,
	searchrange = 50,						
	name = 'a Fish',
	width = 17, 							
	height = 17,							
	movementSpeed = 2,							
	dmg = 5,						
	attackrange = 3,
	attackrate = 0.5,
	image = {
		'resources/arrow_up.png', -- 1 - north
		'resources/arrow_right.png', -- 2 - east
		'resources/arrow_down.png', -- 3 - south
		'resources/arrow_left.png' -- 4 - west
	},
	currentState = Gameelement.stateList.default,
	team =  2
}

Barrel = Fish:new{
	currentImage = 2, -- NOTE: ?? what's that?
	exp = 10,
	searchrange = 0,						
	name = 'barrel',
	width = 25, 							
	height = 25,							
	movementSpeed = 0,							
	dmg = 0,						
	attackrange = 0,
	attackrate = 0.5,
	expWhenKilled = 10,
	sprite = "resources/barrel.png", -- 1 - north,
	team =  2,
	stateList = {
		dead = {
			name = "dead",
			actions = {
				function (t)
					t.team = 100
					shootFirebalAllDirections(t, 1, 5)
					-- animation TODO: encapsule
					local size = 96
					local  anim = newAnimation(img_explosion, size, size, 0.1, 0)
					anim:setMode("once")
					table.insert(once_animations,{anim, t.center[1] - size/2, t.center[2] - size/2 })
					-- play BOOOOOOOM!
					love.audio.rewind(sound_explosion_fire)
					love.audio.play(sound_explosion_fire)
					-- change state
					t:changeState(t.stateList.destroy)
				end
			}
		}
	},
	currentState = Enemy.stateList.idle
}

Chest = Fish:new{
	exp = 10,
	searchrange = 0,						
	name = 'a Chest',
	width = 25, 							
	height = 25,							
	movementSpeed = 0,							
	dmg = 0,						
	attackrange = 0,
	attackrate = 0.5,
	expWhenKilled = 10,
	image = {
		"resources/chest01_outline.png"
		--"resources/chest01_outline_open.png" -- 1 - north
	},
	team =  2,
	stateList = {
		dead = {
			name = "dead",
			actions = {
				function (t) 
					t.image = {"resources/barrel.png"}
				end
			}
		}
	},
	currentState = Enemy.stateList.idle
}

FollowingDog = Fish:new{
	name = "FollowingDog",
	width = 35,
	height = 35,
	sprite = "resources/cat.png", 
	--enable blood
	blood = true,
	stateList = {
		following = {
			name = "following",
			actions = {
				function (t) 
					if t.misc.follows then
						t.center = {t.misc.follows.center[1] - 40, t.misc.follows.center[2] - 40}
					end
				end
			}
		}
	},
	misc = {follows = nil} -- TODO: somthing to put the followed object reference in. weak table. holds only things that exist
}

FollowingDog.currentState = FollowingDog.stateList.following


